<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="JavaScript" src="${pageContext.request.contextPath}/jsframe/jquery-2.1.1.js" ></script>

<script type="text/javascript" language="JavaScript">
        function submit_1() {
        	//alert("ok");
            var customerArray = new Array();
            customerArray.push({id: "1", name: "a"});
            customerArray.push({id: "2", name: "b"});
            var student={id: "1", name: "nsl",'fn':'string'};
            $.ajax({
                url: "${pageContext.request.contextPath}/bindData/requestBodyString",
                type: "post",
                //contentType : 'text/html;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: JSON.stringify(student),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                success: function(data){
                    console.log(data);
                },
                error: function(res){
                    alert(res.responseText);
                }
            });
        }  
            function submit_2() {
            	//alert("ok");
                var student={id: "1", name: "nsl",'fn':'string'};
                $.ajax({
                    url: "${pageContext.request.contextPath}/bindData/requestBodyObject",
                    type: "POST",
                    contentType : 'application/json;charset=utf-8', //设置请求头信息
                    dataType:"json",
                    data: JSON.stringify(student),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                    //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                    success: function(data){
                        console.log(data);
                    },
                    error: function(res){
                        alert(res.responseText);
                    }
                });
        }
            
        function submit_3() {
        	//alert("ok");
            var customerArray = new Array();
            customerArray.push({id: "1", name: "nsl"});
            customerArray.push({id: "2", name: "张三"});
            var student={id: "1", name: "nsl",'fn':'string'};
            $.ajax({
                url: "${pageContext.request.contextPath}/bindData/requestBodyList2String",
                type: "POST",
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                success: function(data){
                    console.log(data);
                },
                error: function(res){
                    alert(res.responseText);
                }
            });
        }  
        
        function submit_4() {
        	//alert("ok");
            var customerArray = new Array();
            customerArray.push({id: "1", name: "nsl"});
            customerArray.push({id: "2", name: "张三"});
            var student={id: "1", name: "nsl",'fn':'string'};
            $.ajax({
                url: "${pageContext.request.contextPath}/bindData/requestBodyList2List",
                type: "POST",
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                success: function(data){
                    console.log(data);
                },
                error: function(res){
                    alert(res.responseText);
                }
            });
        }  
        
        function submit_5() {
        	//alert("ok");
            var customerArray = new Array();
            customerArray.push({id: "1", name: "nsl"});
            customerArray.push({id: "2", name: "张三"});
            var listArray=new Array();
            listArray.push(customerArray);
            var student={id: "1", name: "nsl",'fn':'string'};
            $.ajax({
                url: "${pageContext.request.contextPath}/bindData/requestBodyListArray2List",
                type: "POST",
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: JSON.stringify(listArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                success: function(data){
                    console.log(data);
                },
                error: function(res){
                    alert(res.responseText);
                }
            });
        }  
        
        function submit_6() {
        	//alert("ok");
            var customerArray = new Array();
            customerArray.push({id: "1", name: "nsl"});
            customerArray.push({id: "2", name: "张三"});
            var listArray=new Array();
            listArray.push(customerArray);
            var school=new Object();
            school.name="qh";
            school.studentList=listArray;
            $.ajax({
                url: "${pageContext.request.contextPath}/bindData/requestBodySchool2School",
                type: "POST",
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: JSON.stringify(school),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
                //data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
                success: function(data){
                    console.log(data);
                },
                error: function(res){
                    alert(res.responseText);
                }
            });
        }  
</script>
</head>
<body>
	<h1>使用String 接收 obj</h1>
    <input id="submit" type="button" value="Submit" onclick="submit_1();">
    <br> <br>

	<h2>使用obj 接收 obj</h1>
    <input id="submit2" type="button" value="Submit" onclick="submit_2();">
    <br> <br>
    
    <h3>使用string 接收 list</h1>
    <input id="submit2" type="button" value="Submit" onclick="submit_3();">
    <br> <br>
    
    <h3>使用list 接收 list</h1>
    <input id="submit2" type="button" value="Submit" onclick="submit_4();">
    <br> <br>

	 <h3>使用list array 接收 list array</h1>
    <input id="submit2" type="button" value="Submit" onclick="submit_5();">
    <br> <br>
    
     <h3>使用school 接收  school</h1>
    <input id="submit2" type="button" value="Submit" onclick="submit_6();">
    <br> <br>
</body>
</html>